Skip to content

Conversation

RAprogramm
Copy link
Owner

Closes #39

Changes

Added automatic release workflow that triggers after successful CI completion on main branch.

Workflow Features

Version Detection:

  • Compares local Cargo.toml version with crates.io version
  • Uses semver comparison to determine if release needed
  • Only releases when local version > crates.io version

Idempotent Checks:

  • Checks if git tag already exists
  • Checks if GitHub release already exists
  • Skips steps if already completed (safe to re-run)

Changelog Generation:

  • Extracts commits since last release
  • Groups by conventional commit type:
    • Features (feat)
    • Bug Fixes (fix)
    • Performance (perf)
    • Refactoring (refactor)
    • Documentation (docs)
    • Tests (test)
    • CI/CD (ci)
    • Chore (chore)
  • Excludes [skip ci] commits
  • Links commits and issues in changelog
  • Adds full changelog comparison link

Automated Steps:

  1. Compare versions (local vs crates.io)
  2. Generate changelog from commits
  3. Create annotated git tag
  4. Create GitHub Release with changelog
  5. Publish to crates.io (with retry logic)

Error Handling:

  • 5 retry attempts for crates.io publish
  • Exponential backoff between retries
  • Skips if already published

Benefits

  • No manual version bumping in CI
  • No manual tag creation
  • No manual changelog writing
  • Automatic crates.io publishing
  • Professional release notes
  • Faster release cycle
  • Conventional commits enforcement

How to Use

  1. Bump version in Cargo.toml (e.g., 0.1.0 → 0.1.1)
  2. Commit with conventional commit format
  3. Push to main
  4. Wait for CI to pass
  5. Auto-release workflow runs automatically
  6. Tag, release, and crates.io publish happen automatically

Testing

  • Workflow syntax validated
  • REUSE 3.3 compliance maintained
  • Will be tested when next version is bumped

Similar Implementation

Based on masterror auto-release workflow: https://github.com/RAprogramm/masterror/.github/workflows/auto-release.yml

- Add auto-release workflow triggered after successful CI
- Compare local Cargo.toml version with crates.io version
- Automatically create tags and GitHub releases when version bumped
- Generate changelog from conventional commits
- Publish to crates.io automatically

Workflow features:
- Triggers on successful CI completion on main branch
- Uses semver comparison to detect new versions
- Checks if tag/release already exist (idempotent)
- Groups commits by type (feat, fix, docs, etc.)
- Generates formatted changelog with links
- Creates annotated git tags
- Creates GitHub releases with changelog
- Publishes to crates.io with retry logic (5 attempts)

Benefits:
- No manual version management needed
- Automatic changelog generation
- Faster release cycle
- Professional release notes
- Idempotent (safe to re-run)

Related: Closes #39
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +23 to +25
- uses: actions/checkout@v4
with:
fetch-depth: 0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Check out tested commit before releasing

This workflow is triggered by workflow_run after the CI job succeeds, but actions/checkout@v4 is invoked without a ref and therefore checks out whatever happens to be at main when the job starts. If another commit lands on main before this job begins (for example a version bump whose CI run is still in progress or even fails), the release pipeline will tag and publish that newer code despite it never having completed CI. Fetch the github.event.workflow_run.head_sha so the release is built from the exact commit that actually passed CI.

Useful? React with 👍 / 👎.

@RAprogramm RAprogramm merged commit 20fae31 into main Oct 19, 2025
3 checks passed
@RAprogramm RAprogramm deleted the 39 branch October 19, 2025 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add automatic release workflow

1 participant